#include "testlineedit.h"
#include <QtWidgets/QApplication>
#include <QtWidgets>

QPushButton* CreateLineEditRightBtn(QLineEdit* ptr)
{
    auto btn = new QPushButton();
    auto layout = new QHBoxLayout();
    btn->setCursor(Qt::ArrowCursor);
    layout->addStretch();
    layout->addWidget(btn);
    layout->setContentsMargins(0, 0, 0, 0);
    ptr->setLayout(layout);
    ptr->setStyleSheet(QString("QLineEdit{border:1px solid #EEE;border-radius:4px;padding-right:14px;}"));
    ptr->setStyleSheet(QString("QLineEdit:focus{border-color:#bbbec4;}"));
    
    btn->setStyleSheet(QString("QPushButton { width:  16px; \
                                height: 16px; \
                                qproperty-flat: true; \
                                margin-right: 4px; \
                                border: none; \
                                border-width: 0; \
                                border-image: url(:/testlineedit/resource/view-refresh.png) 0 0 0 0 stretch stretch;}"));
    return btn;
}


int main(int argc, char *argv[])
{
    //C:\Users\Administrator\AppData\Local\Microsoft\VisualStudio\17.0_860d1bd1\Extensions\u0ydf2sa.aya\qrceditor.exe
    QApplication a(argc, argv);
#if 0
    testlineedit w;
    w.show();
#endif // 0
    QWidget widget{};
    auto lineedit = new QLineEdit(&widget);
    auto btn = CreateLineEditRightBtn(lineedit);
    lineedit->setGeometry(20, 20, 200, 26);
    widget.resize(400, 100);
    widget.show();
    QObject::connect(btn, &QPushButton::clicked, [] {QMessageBox::information(nullptr, "test", "fuck"); });

    return a.exec();
}
